<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<script src="${path}/v2/console/js/ztree/jquery-1.4.4.min.js"></script>
<script src="${path}/v2/console/js/ztree/jquery.ztree.core-3.5.js"></script>
<link rel="stylesheet" href="${path}/v2/console/css/ztree/zTreeStyle/zTreeStyle.css">
<script language="JavaScript">
   var zTreeObj;
   var setting = {
		   data: {
               key: {
                   id: "id",
                   pId: "parentId",
                   name: "name"
               },
               simpleData: {
                   enable: true 
                   //checked: true
               }
           },
           callback: {
				beforeClick: beforeClick,
				onClick: onClick
			},
           view: {
 				fontCss: getFont,
 				nameIsHTML: true
 				}
		};
   function getFont(treeId, node) {
		return node.font ? node.font : {};
	}
   
   var log, className = "dark";
	function beforeClick(treeId, treeNode, clickFlag) {
		className = (className === "dark" ? "":"dark");
		return (treeNode.click != false);
	}
	function onClick(event, treeId, treeNode, clickFlag) {
		var level;
		if(treeNode.pId == null){
			level = 1;
		}else{
			level = 2;
		}
		$("#frame-contect").attr("src","toUpdateSiteNode.html?id="+treeNode.id + "&level=" + level);
	}
   
   $(document).ready(function(){
	   
	   $.ajax({
			type : "post",
			url : "topNodeTree.html",
			dataType : "json",
			data:{id:0},
			async : false,
			success : function(data) {
				if(data.ajax_status == "ajax_status_success"){
					 zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, data.list);
				}else{
					alert(data.msg);
				}
				return false;
			},
			error : function(XMLHttpRequest, textStatus, errorThrown){
	          alert("出错了！");
	       }
		});
   });
  </script>
<div class="menu-box">
		<div style="height: 20px;padding:10px;border-bottom: 1px solid gray;">
			<h2>栏目管理</h2>
		</div>
		<div>
		   <ul id="treeDemo" class="ztree"></ul>
		</div>
</div>